package io.gitee.itxinmeng.encrypt.spring.boot.common.encrypt;

import io.gitee.itxinmeng.encrypt.spring.boot.common.encrypt.strategy.IEncryptStrategy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author mx
 */
public enum EncryptMethodFactory {
    INSTANCE;
    private Map<String, IEncryptStrategy> encryptMethodMap = new ConcurrentHashMap<>();

    public IEncryptStrategy getEncryptStrategy(String encryptMethod){
        return encryptMethodMap.get(encryptMethod);
    }
    public IEncryptStrategy addEncryptStrategy(EncryptMethodEnum encryptMethod,IEncryptStrategy encryptStrategy){
        return encryptMethodMap.put(encryptMethod.name(),encryptStrategy);
    }
    public enum EncryptMethodEnum {
        AES("Body AES加密"), RSA("body RSA加密"), SIGN_AND_AES("签名和Body AES加密");
        private String desc;
        EncryptMethodEnum(String desc){
            this.desc = desc;
        }
        public String getDesc() {
            return desc;
        }
        public void setDesc(String desc) {
            this.desc = desc;
        }
    }
}
